*******************************************
** ADRIAN SHIN                          ***
** Primary Resources, Secondary Labor   ***
** August, 2018                         ***
*******************************************
*This material is based upon work supported by the National Science Foundation Graduate Student Research Fellowship under Grant No. DGE 0718128, National Science Foundation Doctoral Dissertation Research Improvement Grants No. SES 1559661, and National Science Foundation (NSF) Graduate Research Opportunities Worldwide.


* December 7, 2021

 set matsize 500
 set more off

 use "C:\12032021\data collections\Adrian J Shin\Shin, 2019, ISQ\replication materials\Replication, Whan\Shin ISQ Main Dataset_WithCName", clear

 iis ccode
 tis year
 

*** 385, Norway due to large residual: a case study ***


*** Table 1: replication
* Model 1, Table 3
xtpcse forward_immipol immipol ln_oil_income_pc i.year i.ccode i.ccode#c.time if regime==0, noconst
est store tab1
* Model 6, Table 3
xtpcse forward_immipol immipol ln_oil_income_pc ln_gdp_pc gdp_growth ln_population polity_2 i.year i.ccode i.ccode#c.time if regime==0 & year>1945, noconst
est store tab2
* Model 19, Table 5
xtpcse forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 sstpy ptaxpy i.year i.ccode i.ccode#c.time if regime==0 & year>1945, noconst
est store tab3
* Model 21, Table 5
xtpcse forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote i.year i.ccode i.ccode#c.time if regime==0 & year>1945, noconst
est store tab4
esttab tab*, b(3) se(3) stats(N ll r2) keep(immipol ln_oil_income_pc import_duties_100 c.ln_oil_income_pc#c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote)
estimates clear


*** Figure 1: finding outlier: Norway
* Model 1, Table 3
reg forward_immipol immipol ln_oil_income_pc i.year i.ccode i.ccode#c.time if regime==0, /*noconst*/
rvfplot, yline(0) mlabel(cname)
* Model 6, Table 3
reg forward_immipol immipol ln_oil_income_pc ln_gdp_pc gdp_growth ln_population polity_2 i.year i.ccode i.ccode#c.time if regime==0 & year>1945, /*noconst*/
rvfplot, yline(0) mlabel(cname)
* Model 19, Table 5
reg forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 sstpy ptaxpy i.year i.ccode i.ccode#c.time if regime==0 & year>1945, /*noconst*/
rvfplot, yline(0) mlabel(cname)
* Model 21, Table 5
reg forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote i.year i.ccode i.ccode#c.time if regime==0 & year>1945, /*noconst*/
rvfplot, yline(0) mlabel(cname)


*** Table 2: dropping outlier: Norway
* Model 1, Table 3
xtpcse forward_immipol immipol ln_oil_income_pc i.year i.ccode i.ccode#c.time if regime==0 & ccode~=385, noconst
est store uab1
* Model 6, Table 3
xtpcse forward_immipol immipol ln_oil_income_pc ln_gdp_pc gdp_growth ln_population polity_2 i.year i.ccode i.ccode#c.time if regime==0 & year>1945 & ccode~=385, noconst
est store uab2
* Model 19, Table 5
xtpcse forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 sstpy ptaxpy i.year i.ccode i.ccode#c.time if regime==0 & year>1945 & ccode~=385, noconst
est store uab3
* Model 21, Table 5
xtpcse forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote i.year i.ccode i.ccode#c.time if regime==0 & year>1945 & ccode~=385, noconst
est store uab4
esttab uab*, b(3) se(3) stats(N ll r2) keep(immipol ln_oil_income_pc import_duties_100 c.ln_oil_income_pc#c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote)
estimates clear


*** Figure 2: finding leverage and outlier
* Model 1, Table 3
reg forward_immipol immipol ln_oil_income_pc i.year i.ccode i.ccode#c.time if regime==0, /*noconst*/
lvr2plot, mlabel(cname)
* Model 6, Table 3
reg forward_immipol immipol ln_oil_income_pc ln_gdp_pc gdp_growth ln_population polity_2 i.year i.ccode i.ccode#c.time if regime==0 & year>1945, /*noconst*/
lvr2plot, mlabel(cname)
* Model 19, Table 5
reg forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 sstpy ptaxpy i.year i.ccode i.ccode#c.time if regime==0 & year>1945, /*noconst*/
lvr2plot, mlabel(cname)
* Model 21, Table 5
reg forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote i.year i.ccode i.ccode#c.time if regime==0 & year>1945, /*noconst*/
lvr2plot, mlabel(cname)


*** Table 3: droping leverage and outlier
* Model 1, Table 3
xtpcse forward_immipol immipol ln_oil_income_pc i.year i.ccode i.ccode#c.time if regime==0 & ccode~=2 & ccode~=385, noconst
est store vab1
* Model 6, Table 3
xtpcse forward_immipol immipol ln_oil_income_pc ln_gdp_pc gdp_growth ln_population polity_2 i.year i.ccode i.ccode#c.time if regime==0 & year>1945 & ccode~=732 & ccode~=385, noconst
est store vab2
* Model 19, Table 5
xtpcse forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 sstpy ptaxpy i.year i.ccode i.ccode#c.time if regime==0 & year>1945 & ccode~=200 & ccode~=385, noconst
est store vab3
* Model 21, Table 5
xtpcse forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote i.year i.ccode i.ccode#c.time if regime==0 & year>1945 & ccode~=230 & ccode~=385, noconst
est store vab4
esttab vab*, b(3) se(3) stats(N ll r2) keep(immipol ln_oil_income_pc import_duties_100 c.ln_oil_income_pc#c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote)
estimates clear


/** Figure 3: Figure 1a, based on Model 19, Table 5 **/
qui xtpcse forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 sstpy ptaxpy i.year i.ccode i.ccode#c.time if regime==0 & year>1945 & ccode~=200 & ccode~=385, noconst
qui margins, dydx(ln_oil_income) at(import_duties_100=(0(2)18))
marginsplot, xsize(5) ysize(6) addplot(hist import_duties_100 if import_duties_100<18 & import_duties_100>0 & regime==0 & year>1945 & ccode~=200 & ccode~=385, yaxis(2) xscale(range(0(2)18)) yscale(range(-.04(.01).04)) yscale(axis(2) range(0 .5) off)lc(white%0) fcolor(gs14%60) xlabel(0(2)18)) ylabel(-.04(.01).04) recast(line) recastci(rarea) ciopts(fc(emidblue%70) lc(white%0)) yline(0) xtitle(Tariff Rate, size(medium)) title("") ytitle("") legend(off) graphregion(fcolor(white) lcolor(white)) 
graph save "Figure 1a",replace
graph export "Figure 1a.pdf", replace
/** Figure 1b, based on Model 21, Table 5 **/
qui xtpcse forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote i.year i.ccode i.ccode#c.time if regime==0 & year>1945 & ccode~=230 & ccode~=385, noconst
qui margins, dydx(ln_oil_income) at(import_duties_100=(0(2)18))
marginsplot, xsize(5) ysize(6) addplot(hist import_duties_100 if import_duties_100<18 & import_duties_100>0 & regime==0 & year>1945 & ccode~=230 & ccode~=385, yaxis(2) xscale(range(0(2)18)) yscale(range(-.04(.01).04)) yscale(axis(2) range(0 .5) off)lc(white%0) fcolor(gs14%60) xlabel(0(2)18)) ylabel(-.04(.01).04) recast(line) recastci(rarea) ciopts(fc(emidblue%70) lc(white%0)) yline(0) xtitle(Tariff Rate, size(medium)) title("") ytitle("") legend(off) graphregion(fcolor(white) lcolor(white)) 
graph save "Figure 1b",replace
graph export "Figure 1b.pdf", replace


*** Table 4: robust regression
* Model 1, Table 3
rreg forward_immipol immipol ln_oil_income_pc i.year i.ccode i.ccode#c.time if regime==0
est store wab1
* Model 6, Table 3
rreg forward_immipol immipol ln_oil_income_pc ln_gdp_pc gdp_growth ln_population polity_2 i.year i.ccode i.ccode#c.time if regime==0 & year>1945
est store wab2
* Model 19, Table 5
rreg forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 sstpy ptaxpy i.year i.ccode i.ccode#c.time if regime==0 & year>1945
est store wab3
* Model 21, Table 5
rreg forward_immipol immipol c.ln_oil_income_pc##c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote i.year i.ccode i.ccode#c.time if regime==0 & year>1945
est store wab4
esttab wab*, b(3) se(3) stats(N ll r2) keep(immipol ln_oil_income_pc import_duties_100 c.ln_oil_income_pc#c.import_duties_100 ln_gdp_pc gdp_growth ln_population polity_2 reer_annual sstpy ptaxpy rwpvote)
estimates clear


















